
#ifndef BASEENGINE
#define BASEENGINE

#include "Thread.h"

#include "Graphic.h"

#include "WorkCellManager.h"

#include "WorkCell.h"

class UpdateCell : public Cell
{
public :
	UpdateCell(){}
	~UpdateCell(){}
public :
	virtual bool OnUpdate(double NowTime,double PastTime){return true;}
};

class RenderCell : public Cell
{
public :
	RenderCell(){}
	~RenderCell(){}
public :
	virtual bool OnWork(){return true;}

};



class BaseEngine
{
public :
	BaseEngine();
	~BaseEngine();

public :
	bool Initialize(ThreadControler * pThreadControler = NULL,UpdateCell * pUpdateCell = NULL,RenderCell * pRenderCell = NULL);
	void Update(double NowTime,double PastTime);
	void Render(double NowTime,double PastTime);
	double GetNowTime();
	//double GetFromBenginPastTime();
public :
	void AddThreadWorker(ThreadWorker* pWorker);
	void AddThreadWorkerEvent(ThreadEvent* pEvent);
	void TickRunGo();
private :
	bool m_IsTickRunning;
	double m_EngineTickBeginTime;
	double m_EngineTickEndTime;
	//ThreadControler* m_ThreadControlor;
	bool m_IsMultithreadRender;
	GraphicSystem* m_pGraphicSystem;
	//WorkCellManager* m_pWorkCellManager;
	ThreadControler* m_pThreadControler;
	UpdateCell * m_pUpdateCell;
	RenderCell * m_pRenderCell;
	//ThreadWorker* m_pMainThreadWorker;
};

void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext );
void CALLBACK OnD3D11FrameRender( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, double fTime,
                                  float fElapsedTime, void* pUserContext );

#endif